/* 
 * Copyright [2018] [Alex/libo(liboms@hotmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.guava.array;

import java.util.List;
import com.hyts.guava.object.Objects;

/** 
 * @title Arrays.java  
 * @package com.hyts.guava.array  
 * @description 原生类型数组是处理原生类型集合的最有效方式<br>
 * 				 （从内存和性能双方面考虑）<br>
 * 				  。Guava 为此提供了许多工具方<br>
				 法。<br>  
 * @see java.util.Arrays
 * @author libo/Alex
 * @email liboms@hotmail.com/liboware@163.com  
 * @date 2018年5月11日 
 * @version V1.0 
 */
public final class Arrays {
	
	/**  
	 * <b>toList：数据转换为List集合支持泛型</b>
	 * <p>数据转换为List集合支持泛型</p>
	 * @param array
	 * @return
	 * @exception
	 */ 
	public static <T> List<T> toList(T[] array){
		Objects.checkNull(array);
		return java.util.Arrays.asList(array);
	}
	
	/**  
	 * <b>toList：数据转换为List集合支持泛型</b>
	 * <p>数据转换为List集合支持泛型</p>
	 * @param array
	 * @return
	 * @exception
	 */ 
	@SuppressWarnings("unchecked")
    public static <T> T[] toArray(List<T> list){
		Objects.checkNull(list);
		return (T[]) list.toArray(new Object[list.size()]);
	}
	
}
